<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>重置密码</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">     
    <meta content="yes" name="apple-mobile-web-app-capable">     
    <meta content="black" name="apple-mobile-web-app-status-bar-style">     
    <meta content="telephone=no" name="format-detection">
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" type="text/css" href="/H5/css/sm.min.css" />
    <link rel="stylesheet" type="text/css" href="/H5/css/login.shell.css?v=2" />
</head>
<body>
    <div class="page-group ms-controller" :controller="reset">
        <div class="page page-current">
            <div class="content">
                <div class="login_shell">
                    <div class="login_logo login_logo01"><a href="/H5"><img src="/logo" class="maxWidth" /></a></div>
                    <div class="login_inpt login_inpt01">
                        <input type="text" :duplex="@phone" style="width: 73%" class="number_tel" placeholder="请填写您的手机号码"/>
                        <span style='font-size: .65rem;color: #fff;width: 27%;text-align: center;float:right; margin-top: 1.2rem; border-radius: 5px; padding: 4px; background-color: #f48a00;' class='getCode' :on-click="@getCode">获取验证码</span>
                        <input type="text" name="code" class="number_password" :duplex="code" placeholder="验证码"/>
                        <input type="password" autocomplete="off" name="password" :duplex="@password" class="number_password1" placeholder="新密码"/>
                        <input type="password" autocomplete="off" name="password" :duplex="@confirm" class="number_password1" placeholder="确认新密码"/>
                    </div>
                    <div class="login_button">
                        <button id="reset" :on-click="@reset">重置密码</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script type='text/javascript' src='/H5/js/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/avalon.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/simpleStorage.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/mall.js?v=10' charset='utf-8'></script>
<script>
    var reset = avalon.define({
        $id: "reset",
        phone: "",
        code:"",
        password: "",
        confirm: "",
        getCode: function(){
            if( $('.getCode').text() == "获取验证码" ){
                var time = 60;
                $('.getCode').text( time );
                Mall.request( "/api/GetPwdSmsCode", {mobile: reset.phone} )
                    .always( function( data ){
                        if( data.error_code == 0 ){
                            var timer = setInterval( function(){
                                $('.getCode').text( time );
                                time -- ;
                                if( time <= 0 ){
                                    $('.getCode').text( "获取验证码" );
                                    clearInterval( timer )
                                }
                            },1000 )
                            $.toast( "获取验证码成功", 1000, "success" );
                        }
                        else{
                            $('.getCode').text( "获取验证码" );
                        }
                    } )
            }
        },
        reset: function(){
            if( Mall.LOCK ){
                return
            }
            var postData = {
                mobile: reset.phone,
                new_password: reset.password,
                confirm_password: reset.confirm,
                code: reset.code
            }
            Mall.LOCK = true;
            Mall.request( "/api/ResetPassword", postData )
                .always( function( data ){
                    if( data.error_code == 0 ){
                        $.toast( "密码重置成功", 1000, "success", function(){
                            window.location.href="/H5/login";
                        } );
                    }
                    Mall.LOCK = false;
                } )
        }
    })
    avalon.scan( document.body )
</script>
</body>
</html>
